﻿using System;

namespace Finance
{
	public struct DateTimeInterval
	{
		public DateTime Start;

		public DateTime End;

		public TimeSpan Duration
		{
			get { return End.Subtract(Start); }
			set { End = Start.Add(value); }
		}

		public DateTimeInterval(DateTime start, DateTime end)
		{
			Start = start;
			End = end;
		}

		public static DateTimeInterval Now
		{
			get
			{
				DateTime now = DateTime.Now;
				return new DateTimeInterval(now, now);
			}
		}

		public static DateTimeInterval Day(DateTime dateTime)
		{
			return new DateTimeInterval(
				new DateTime(dateTime.Year,dateTime.Month, dateTime.Day,0,0,0,0),
				new DateTime(dateTime.Year,dateTime.Month, dateTime.Day, 23, 59,59,999));
		}
	}
}
